package com.tuzhi.sys.web.controller;

import com.dtflys.forest.annotation.Get;
import com.tuzhi.base.web.vo.AjaxResultVO;
import com.tuzhi.common.domain.ResultBO;
import com.tuzhi.common.helper.ResultHelper;
import com.tuzhi.utils.RsaEncipherUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;



@Api(tags = "RSA加密")
@RestController
@RequestMapping("/Encipher")
public class RsaEncipherController {

    @Autowired
    RsaEncipherUtil rsaEncipherUtil;
    @ApiOperation("获取公钥")
    @GetMapping("/publicKey")
    public ResultBO getPublicKey() throws Exception {
        Map<String, String> publicKeyAndPrivateKey = rsaEncipherUtil.getPublicKeyAndPrivateKey();
        //公钥

        String publicKeyStr = publicKeyAndPrivateKey.get(RsaEncipherUtil.PUBLIC_KEY_STR);
        HashMap<String, String> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("publicKeyStr", publicKeyStr);
        return ResultHelper.success().setData(stringStringHashMap);

    }
}
